package com.Web;


import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import util.DateUtil;

import com.Dao.TaskDao;
import com.entity.Employee;

import com.entity.Task;


public class savaAddTk extends HttpServlet {

	private static final long serialVersionUID = 1L;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			HttpSession session = request.getSession();
			
			String id = request.getParameter("id");
			Employee em = (Employee) session.getAttribute("em");
			
			String Tname  = request.getParameter("name");
			String Tdesc = request.getParameter("area");
			String state = request.getParameter("zhuang");
			String levle = request.getParameter("ji");
			String begin = request.getParameter("begin");
			String end = request.getParameter("end");
			String ralee = request.getParameter("jin");
			
			TaskDao dao = new TaskDao();
			Task tk=new Task();
			
			tk.setName(Tname);
			tk.setDesc(Tdesc);
			tk.setState(state);
			tk.setEndtime(end);
			tk.setBegintime(begin);
			tk.setLevel(levle);
			tk.setCreatetime(DateUtil.getNow());
			tk.setEmployeeid(em.getId());
			tk.setGoalid(Integer.parseInt(id));
			tk.setRale(Integer.parseInt(ralee));
			dao.save(tk);
	
			session.setAttribute("tk", tk);
			request.getRequestDispatcher("/WEB-INF/views/task.jsp").forward(request, response);
	
	}
}
